本文共计2685字,预计需要花费 4分钟才能阅读完成。
Debian 13 稳定版 历经两年零两个月的打磨,于 8 月 9 日正式亮相,代号 “Trixie”。手边正有一台运行 Debian 12 的 测试服务器,与生产环境的谨慎迥然不同,它的信条只有一句——有更新就马上升,第一时间畅享最新特性。
🛠️ 准备工作
- 🖥️ 除非你使用的是物理服务器,或者 KVM 架构的 VPS / 云主机(且没有使用奇怪定制或修改的内核),否则升级时更新内核有一定几率导致 Grub 加载失败,⚠️ 切记备份重要数据!
- 🚫 OpenVZ 6 和 LXC 架构 的 VPS 无法升级,因为它们没有独立内核。
- ⚠️ 再强调一遍:一定要备份重要数据!
- 👑 以下操作需要在 root 用户下完成,请使用
sudo -i
或su root
切换到 root 用户进行操作
🔄 更新系统
apt update
apt upgrade -y
apt full-upgrade -y
apt autoclean
apt autoremove -y
如果内核更新了,可以重启后让其生效,也可以直接继续升级。
🚀 升级系统
1. 更新 APT 源
将 bookworm 替换为 trixie:
sed -i 's/bookworm/trixie/g' /etc/apt/sources.list
sed -i 's/bookworm/trixie/g' /etc/apt/sources.list.d/*.list
sed -i 's/bookworm/trixie/g' /etc/apt/sources.list.d/*.sources
如果没有对应文件会提示诸如 sed: can't read /etc/apt/sources.list.d/*.sources: No such file or directory 的错误,忽略即可。
修改后的 /etc/apt/sources.list
示例
deb https://deb.debian.org/debian trixie main contrib non-free non-free-firmware
deb https://security.debian.org/debian-security trixie-security main contrib non-free non-free-firmware
deb https://deb.debian.org/debian trixie-updates main contrib non-free non-free-firmware
DEB822 格式(/etc/apt/sources.list.d/debian.sources
示例)
Types: deb
URIs: https://deb.debian.org/debian
Suites: trixie trixie-updates trixie-backports
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
Types: deb
URIs: https://security.debian.org/debian-security
Suites: trixie-security
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
从 Debian 12 容器版本及 Debian 13 起,APT 默认采用 DEB822 格式。
若采用该格式,可以删除 /etc/apt/sources.list
,只保留 debian.sources
。
国内服务器可将 deb.debian.org
与 security.debian.org
替换为:
mirrors.tuna.tsinghua.edu.cn
2. 再次更新系统
apt update
apt upgrade -y
apt full-upgrade -y
Debian 13 早期版本可能提示你是否自动转换为 DEB822 格式,可用:
apt modernize-sources
转换后需手动修复 backports 仓库 的 GPG Key。
⚙️ 升级过程中的提示
- 软件更新确认 → 选择
Yes
- 是否自动重启服务 → 选择
Yes
- 配置文件更新 → 默认回车表示保留旧配置(常见于
OpenSSH
等) - 退出 apt-listchanges → 按
q
某些软件更新 systemd 配置时,执行:
systemctl daemon-reload
🧹 清理无用文件
apt autoclean
apt autoremove -y
🔁 重启并验证
reboot
重启后验证版本:
cat /etc/debian_version
# 输出: 13.0
lsb_release -a
# Distributor ID: Debian
# Description: Debian GNU/Linux 13 (trixie)
# Release: 13
# Codename: trixie
uname -a
# Linux upload 6.12.38+deb13-cloud-amd64 ...
✅ 此时你的系统已成功升级到 Debian 13 Trixie 及最新内核。
总结
从 Debian 12 升级到 Debian 13 的流程包括:
- 首先确认架构(KVM/物理机可升级,OpenVZ 6 和 LXC 不支持)并完整备份数据
- 以 root 身份更新当前系统至最新状态
- 修改 APT 源,将 “bookworm” 替换为 “trixie”,推荐使用 DEB822 格式并可切换国内镜像
- 再次执行更新与全面升级,按提示选择是否更新配置文件和重启服务
- 升级完成后清理无用软件包与依赖,最后重启系统,通过
cat /etc/debian_version
、lsb_release -a
和uname -a
验证版本信息
即可确认已成功升级到 Debian 13 及最新内核。
如果在升级过程中遇到什么问题请留言。如果您有什么想看的内容或者好的建议可以留言或私信。